import { loginApi } from '@/api'

export default {
  namespaced: true,
  state: {
    token: {}
  },
  mutations: {
    setToken(state, token) {
      state.token = token
    },
    removeToken(state) {
      state.token = {}
    }
  },
  actions: {
    async loginApi(context, dataMsg) {
      try {
        // console.log(1)
        const { data } = await loginApi(dataMsg)
        // console.log(res)
        // console.log('2')

        context.commit('setToken', data.token)
      } catch (error) {
        console.log(error)
      }
    }
  }
}
